<?php

declare(strict_types=1);

namespace app\admin\validate\auth;

use sheep\validate\Backend;

class Role extends Backend
{
    protected $rule = [
        'parent_id' => 'require|between:0,99999',
        'name' => 'require|chsDash|unique:admin_role',
        'code' => 'require|alphaDash|unique:admin_role',
        'rules' => 'array'
    ];

    protected $message  =   [
        'parent_id.require'     => '请选择上级角色组',
        'parent_id.between'     => '请选择正确的上级角色组',
        'name.require'     => '角色名称必须填写',
        'name.chsDash'     => '角色名称只能是汉字、字母、数字和下划线_及破折号-',
        'name.unique'     => '角色名称不能重复',
        'code.require'     => '角色标识必须填写',
        'code.alphaDash'     => '角色标识只能是字母和数字，下划线_及破折号-',
        'code.unique'     => '角色标识不能重复',
        'rules.require'     => '菜单权限必须选择',
        'rules.array'     => '菜单权限格式不正确',
    ];


    protected $scene = [
        'add'  =>  ['parent_id', 'name', 'code', 'rules'],
    ];
}
